import sys,urllib2,getpass

class TerminalPassword(urllib2.HTTPPasswordMgr):
    def find_user_password(self,realm,authurl):
	retval = urllib2.HTTPPasswordMgr.find_user_password(self,realm,authurl)

    	if retval[0] == None and reval[1] == None:
    		sys.stdout.write("Login require %s and %s"%(realm,authurl))
		sys.stdout.wirte("username = ")
		username = sys.stdin.readline().rstrip()
    		password = getpass.getpass().rstrip()
    		return (username,passwor)
   	 else:
    		return retval
	
req = urllib2.Request(sys.argv[1])
opener = urllib2.build_opener(urllib2.HTTPBasicAuthHandler(TerminalPassword()))
fd = opener.open(req)
info  = fd.info()
for i in info:
	print i

